package com.example;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
import org.springframework.beans.factory.annotation.Value;

import java.sql.Types;
import java.util.Collections;

public class CodeGenerator {

    private static final String url = "jdbc:mysql://localhost:3306/e-goods-map?useUnicode=true&characterEncoding=utf-8&useSSL=false";

    private static final String username = "root";

    private static final String password = "yjc991010";

    public static void main(String[] args) {
        FastAutoGenerator.create(url, username, password)
                .globalConfig(builder -> {
                    builder.author("kcyu") // 设置作者
//                            .enableSwagger() // 开启 swagger 模式
                            .outputDir("/Users/kc-yu/project/e-goods-map-backend/src/main/java"); // 指定输出目录

                })
                .packageConfig(builder -> builder
                        .parent("com.kcyu.egoodsmapbackend")
                        .entity("entity")
                        .mapper("mapper")
                        .service("service")
                        .serviceImpl("service.impl")
                        .xml("mapper.xml")
                )
                .strategyConfig(builder ->
                        builder.addInclude("goods") // 设置需要生成的表名
                                .addTablePrefix("t_", "sys_") // 设置过滤表前缀
                                .entityBuilder()
                                .enableLombok()
//                                .enableFileOverride()
                )
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}